package com.eleventwelve.iris.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.opentides.bean.DynamicReport;
import org.opentides.bean.SystemCodes;
import org.opentides.service.ReportService;
import org.opentides.service.SystemCodesService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class ReportsViewController extends AbstractController {
	private ReportService reportService;
	private SystemCodesService systemCodesService;
	private String listView;
	private String jasperPath;

	public ModelAndView handleRequestInternal(HttpServletRequest req,
			HttpServletResponse res) {
		Map<String, Object> mapData = new HashMap<String, Object>();
		
		SystemCodes s = new SystemCodes();
		s.setCategory("REPORT_GROUP");
		s.setOrderOption("numberValue");
		s.setOrderFlow("ASC");
		List<SystemCodes> systemCodesList = systemCodesService.findByExample(s);
		List<DynamicReport> reportList = reportService.findAllReportsOrderByReportGroup();

		mapData.put("systemCodesList", systemCodesList);
		mapData.put("reportList", reportList);
		mapData.put("jasperPath", jasperPath);
		
		return new ModelAndView(listView, mapData);
	}
	
	public void setReportService(ReportService reportService) {
		this.reportService = reportService;
	}

	public void setSystemCodesService(SystemCodesService systemCodesService) {
		this.systemCodesService = systemCodesService;
	}

	public void setListView(String listView) {
		this.listView = listView;
	}

	public void setJasperPath(String jasperPath) {
		this.jasperPath = jasperPath;
	}
}
